package in.saku.jpgms.sorting;

public class InsertionSort {
	
	public static void main(String[] args)
	{
		int[] arr = {5, 4, 9, 22, 14,98, 76,43, 74, 64, 39, 1};
		int i = 0;
		int key = 0;
		for ( int j = 1; j< arr.length; j++)
		{
			key = arr[j];
			
			i = j - 1;
			while ( i >= 0 && arr[i] > key)
			{
				arr[i+1] = arr[i];
				i = i - 1;
			}
			arr[i+1] = key;
		}
		System.out.print("{");
		for ( int k = 0; k< arr.length; k++)
		{
			System.out.print(arr[k]);
			System.out.print(",");
		}
		System.out.print("}");

		

	}

}
